package com.groot.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

public class SimpleDateUtil {
	public static java.sql.Date fomart(java.util.Date data){
		return new java.sql.Date(data.getTime());
	}
	/**
	 * 获取当前时间
	 * @return
	 */
	public static String now() {
	    GregorianCalendar calenda = new GregorianCalendar();
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    return sdf.format(calenda.getTime());
	}
	/**
	 * String转Date
	 * @param nowtimes
	 * @return
	 */
	public static Date StringToDate(String nowtimes){
		Date now = new Date();
		SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd");
		String nowTime = time.format(now);
		Date nowtime = null;
		try {
			nowtime = time.parse(nowTime);
		} catch (ParseException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return nowtime;
	}
	public static String currentYear(){
		GregorianCalendar calenda = new GregorianCalendar();
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
	    return sdf.format(calenda.getTime());
	}
}
